<style src="../../style/statistics.css" scoped></style>
<template>
    <div style="height:100%;" class="padding10">
        <Row class="divBar">
            <!--搜索框-->
                <Col span="14" >
                    填报年度:
                    <Select :value="searchModel.FillInYear" placeholder="全部" :label-in-value="true" @on-change="GetData()" style="width:120px">
                        <Option :value="item.DictValue" v-for="item in CreateYearList" :key="item.DictValue">{{item.DictText}}</Option>
                    </Select>
                    <!-- 分类：
                    <Select v-model="searchModel.Type" placeholder="请选择" :label-in-value="true" @on-change="typeChange" style="width:160px">
                        <Option value="0" >按地区统计</Option>
                        <Option value="1" >按品种统计</Option>
                    </Select> -->
                    <label  v-show="searchModel.Type=='0'&&userInfo.AreaCode=='530000000000'">所属地区:</label>
                    <!-- <Cascader :data="AreaList" change-on-select @on-change='SearchCascaderChange' style="width: 220px;display:inline-block" v-show="searchModel.Type=='0'"></Cascader> -->
                    <Select v-model="searchModel.AreaCode" placeholder="全部" :label-in-value="true" @on-change="SearchCascaderChange" style="width:120px" v-show="searchModel.Type=='0'&&userInfo.AreaCode=='530000000000'">
                        <Option :value="item.value" v-for="item in AreaList" :key="item.value">{{item.label}}</Option>
                    </Select>
                    品种：
                    <Select v-model="searchModel.Pvariety" v-show="searchModel.Type=='1'" style="width:180px" @on-change="GetData()">
                        <Option value="">全部</Option>
                        <Option :value="item.DictText" v-for ="item in VarietyList" :key="item.DictValue">{{item.DictText}}</Option>
                    </Select>
                    <span style="color:red;font-size:18px" v-show="(barShow||mapShow)&&!searchModel.Pvariety">*请选择品种！</span>
                    <Button  type="primary" v-show="listShow" @click="Download()">导出列表</Button> 
                </Col>                      
                <Col span="10"  style="text-align:right;">    
                <RadioGroup v-model="currentButton" @on-change="changeButton" type="button"  size="large">
                        <Radio label="listShow" title="列表"><Icon type="ios-paper" size="35"></Icon></Radio>                            
                        <Radio label="barShow" title="柱状图"><Icon type="stats-bars" size="35"></Icon></Radio>
                        <Radio label="mapShow" title="地图"><Icon type="android-map" size="35"></Icon></Radio>                            
                </RadioGroup>                    
              </Col>                              
            </Row>
            <Row  v-show="listShow">
            <!-- 列表-->
            <div class="col-margin" >
                <!-- <Table v-show="!isVariety"  :columns="columnList" no-data-text="暂无数据" :data="(isCounty)?cdataList:dataList" border :height="clientHeight"></Table> -->
                <Table  :row-class-name="rowClassName" no-data-text="暂无数据" :columns="vcolumnList" :data="(isCounty)?cdataList:dataList" border :height="clientHeight"></Table>
                <!-- <table class="statisTable" :style="tableStyle" v-show="!isCounty">
                    <thead>
                        <tr>
                            <th rowspan="2">{{(searchModel.Type=="1")?'品种':'地区'}}</th>
                            <th colspan="4">全年合计</th>
                            <th colspan="4">其中：大春作</th>
                            <th colspan="4">其中：秋作</th>
                            <th colspan="4">其中：冬作</th>                                                      
                        </tr>
                        <tr>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(dataModel,index) in dataList" :key="index" :style="rowStyle(index,dataList.length)">
                            <td style="text-align:center">
                                {{(searchModel.Type=="1")?dataModel.Pvariety:dataModel.AreaName}}
                            </td>
                            <td>
                                {{dataModel.YArea}}
                            </td>
                            <td> 
                                {{dataModel.YYield}}
                            </td>
                            <td>
                                {{dataModel.YAvgMuYield}}
                            </td> 
                            <td>
                                {{dataModel.YOutput}}
                            </td>
                            <td>
                                {{dataModel.SArea}}
                            </td>  
                            <td>
                                {{dataModel.SYield}}
                            </td>
                             <td>
                                {{dataModel.SAvgMuYield}}
                            </td>
                            <td>
                                {{dataModel.SOutput}}
                            </td>
                            <td>
                                {{dataModel.AArea}}
                            </td>
                            <td>
                                {{dataModel.AYield}}
                            </td> 
                            <td>
                                {{dataModel.AAvgMuYield}}
                            </td> 
                            <td>
                                {{dataModel.AOutput}}
                            </td>
                            <td>
                                {{dataModel.WArea}}
                            </td>
                            <td>
                                {{dataModel.WYield}}
                            </td>
                            <td>
                                {{dataModel.WAvgMuYield}}
                            </td>
                            <td>
                                {{dataModel.WOutput}}
                           </td> 
                        </tr>
                    </tbody>
                </table>
                
                <table class="statisTable" v-show="isCounty" :style="tableStyle">
                    <thead>
                        <tr>
                            <th rowspan="2">品种</th>
                            <th colspan="4">全年合计</th>
                            <th colspan="4">其中：大春作</th>
                            <th colspan="4">其中：秋作</th>
                            <th colspan="4">其中：冬作</th>                                                      
                        </tr>
                        <tr>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                            <th>面积(万亩）</th>
                            <th>总产（万吨）</th>
                            <th>平均亩产（公斤/亩）</th>                            
                            <th>总产值（万元）</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(dataModel,index) in cdataList" :key="index">
                            <td>
                                {{dataModel.Pvariety}}
                            </td>
                            <td>
                                {{dataModel.YArea}}
                            </td>
                            <td> 
                                {{dataModel.YYield}}
                            </td>
                            <td>
                                {{dataModel.YAvgMuYield}}
                            </td> 
                            <td>
                                {{dataModel.YOutput}}
                            </td>
                            <td>
                                {{dataModel.SArea}}
                            </td>  
                            <td>
                                {{dataModel.SYield}}
                            </td>
                             <td>
                                {{dataModel.SAvgMuYield}}
                            </td>
                            <td>
                                {{dataModel.SOutput}}
                            </td>
                            <td>
                                {{dataModel.AArea}}
                            </td>
                            <td>
                                {{dataModel.AYield}}
                            </td> 
                            <td>
                                {{dataModel.AAvgMuYield}}
                            </td> 
                            <td>
                                {{dataModel.AOutput}}
                            </td>
                            <td>
                                {{dataModel.WArea}}
                            </td>
                            <td>
                                {{dataModel.WYield}}
                            </td>
                            <td>
                                {{dataModel.WAvgMuYield}}
                            </td>
                            <td>
                                {{dataModel.WOutput}}
                           </td> 
                        </tr>
                    </tbody>
                </table> -->
            </div>
         </Row>
         <Row v-show="barShow">
            <!--柱状图-->
            <div  id="divBar">
                <Tabs type="card">
                    <TabPane label="全年">
                        <div id="divBarOne" style="border:1px solid #D7DDE4;"></div>
                    </TabPane>
                    <TabPane label="大春">
                        <div id="divBarTwo" style="border:1px solid #D7DDE4; "></div>
                    </TabPane>
                    <TabPane  label="秋作">
                        <div id="divBarThree" style="border:1px solid #D7DDE4; "></div>
                    </TabPane>
                    <TabPane label="冬作">
                        <div id="divBarFour" style="border:1px solid #D7DDE4; "></div>
                    </TabPane>
                </Tabs>
            </div>
        </Row>
        <Row  v-show="mapShow">
            <!--地图展示-->
            <div id="divMap">
                <Tabs type="line">
                    <TabPane label="全年">
                        <div id="divMapOne" style="border:1px solid #D7DDE4;"></div>
                    </TabPane>
                    <TabPane label="大春">
                        <div id="divMapTwo" style="border:1px solid #D7DDE4; "></div>
                    </TabPane>
                    <TabPane  label="秋作">
                        <div id="divMapThree" style="border:1px solid #D7DDE4; "></div>
                    </TabPane>
                    <TabPane label="冬作">
                        <div id="divMapFour" style="border:1px solid #D7DDE4; "></div>
                    </TabPane>
                </Tabs>
            </div>
        </Row>
    </div>
</template>
<script>
export default {
    data() {
        return {
            isVariety:false,//是否按品种查询,searchModel.Type为'1'时true,为0则false
            showType:false,
            dataList:[],//列表对象
            currentButton:'listShow',
            listShow:true,//列表显示控制器
            barShow:false,//柱状图显示控制器
            mapShow:false,//地图显示控制器 
            userInfo: this.GetlocaStorage("potUserinfo"),
            VarietyList:this.GetGroupDict("PotatoVariety"),
            AreaList: [],//所属行政区划数组,
            TableCodeList: this.GetGroupDict("ReportTableName"),//表名称
            CreateYearList: this.GetGroupDict("ReportYear"),//周期
            CycleList: this.GetGroupDict("ReportCycle"),//
            isCounty:false,//是否是县级
            cdataList:[],//县级列表对象
            tableStyle:{
                height:window.innerHeight - 183+'px',
                marginBottom:'50px'
                },
            DataModel: {//编辑模型
                Id: 0,
                ReportId: '',
            },
            //查询模型：根据需求删除不不要查询条件
            searchModel: {
                ReportCode: 'PotYearProduct',
                FillInYear: new Date().getFullYear()+"",
                Type: '1',//0获取地区列表，1获取品种
                AreaCode: this.GetlocaStorage("potUserinfo").AreaCode,
                Pvariety:'',//品种
                Status:'',
                PageNumber: 1, PageSize: 20
            },
            clientHeight: window.innerHeight - 183,//表格默认高度
            columnList:[
                {title:'地区',key:'AreaName',align:'center',fixed:'left',width:180},
                {title:'全年合计',align:'center',children:[
                    {title:'面积(万亩）',key:'YArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'YYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'YAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'YOutput',align:'right',width:120,sortable: true},
                ]},
                {title:'其中：大春作',align:'center',children:[
                    {title:'面积(万亩）',key:'SArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'SYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'SAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'SOutput',align:'right',width:120,sortable: true},
                ]},
                {title:'其中：秋作',align:'center',children:[
                    {title:'面积(万亩）',key:'AArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'AYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'AAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'AOutput',align:'right',width:120,sortable: true},
                ]},
                {title:'其中：冬作',align:'center',children:[
                    {title:'面积(万亩）',key:'WArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'WYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'WAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'WOutput',align:'right',width:120,sortable: true},
                ]},
            ],
            vcolumnList:[
                {title:'品种',key:'Pvariety',align:'center',fixed:'left',width:120},
                {title:'地区',key:'AreaName',align:'center',fixed:'left',width:150},
                {title:'全年合计',align:'center',children:[
                    {title:'面积(万亩）',key:'YArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'YYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'YAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'YOutput',align:'right',width:120,sortable: true},
                ]},
                {title:'其中：大春作',align:'center',children:[
                    {title:'面积(万亩）',key:'SArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'SYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'SAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'SOutput',align:'right',width:120,sortable: true},
                ]},
                {title:'其中：秋作',align:'center',children:[
                    {title:'面积(万亩）',key:'AArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'AYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'AAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'AOutput',align:'right',width:120,sortable: true},
                ]},
                {title:'其中：冬作',align:'center',children:[
                    {title:'面积(万亩）',key:'WArea',align:'right',width:120,sortable: true},
                    {title:'总产（万吨）',key:'WYield',align:'right',width:120,sortable: true},
                    {title:'平均亩产（公斤/亩）',key:'WAvgMuYield',align:'right',width:120,sortable: true},
                    {title:'总产值（万元）',key:'WOutput',align:'right',width:120,sortable: true},
                ]},
            ],
            //柱状图数据
            AreaNameData:[],
            YAreaData:[],
            YYieldData:[],
            YAvgMuYieldData:[],
            YOutputData:[],
            SAreaData:[],
            SYieldData:[],
            SAvgMuYieldData:[],
            SOutputData:[],
            AAreaData:[],
            AYieldData:[],
            AAvgMuYieldData:[],
            AOutputData:[],
            WAreaData:[],
            WYieldData:[],
            WAvgMuYieldData:[],
            WOutputData:[],
            barList0:[],
            barList1:[],
            barList2:[],
            barList3:[],
            //地图数据
            mapType:'',
            echartsItem0:['总面积（万亩）','总产量（万吨）','平均亩产（公斤/亩）','总产值（万元）'],
            echartsItem1:['总面积（万亩）','总产量（万吨）','平均亩产（公斤/亩）','总产值（万元）'],
            echartsItem2:['总面积（万亩）','总产量（万吨）','平均亩产（公斤/亩）','总产值（万元）'],
            echartsItem3:['总面积（万亩）','总产量（万吨）','平均亩产（公斤/亩）','总产值（万元）'],
            GeoData:'',
            MapYAreaData:[],
            MapYYield:[],
            MapYAvgMuYield:[],
            MapYOutput:[],
            MapSAreaData:[],
            MapSYield:[],
            MapSAvgMuYield:[],
            MapSOutput:[],
            MapAAreaData:[],
            MapAYield:[],
            MapAAvgMuYield:[],
            MapAOutput:[],
            MapWAreaData:[],
            MapWYield:[],
            MapWAvgMuYield:[],
            MapWOutput:[],
            mapList0:[],
            mapList1:[],
            mapList2:[],
            mapList3:[],
        }
    },
    mounted() {
        //table高度计算方法
        const that = this;
        window.onresize = () => {
            return (() => {
                that.clientHeight = window.innerHeight - 183;
            })()
        };
    },
    methods: {
        changeButton(n){
            if(n=="listShow")
            {
                this.listShow=true;//显示列表
                this.barShow=false;
                this.mapShow=false;
            }
            else if(n=="barShow")
            {
                this.listShow=false;
                this.barShow=true;//显示柱状图
                this.mapShow=false;
               // this.showPie();
            }
             else if(n=="mapShow")
            {
                this.listShow=false;
                this.barShow=false;//显示地图
                this.mapShow=true;
                //  this.getStatsData();   //获取地区统计数据  
                //this.showMap();
            }
            else{
                 this.listShow=true;//默认显示列表
                 this.barShow=false;
                 this.mapShow=false;
            }
        },
        getDetail(AreaCode){
          var self = this;
          this.$http.get("PotYearProduct/GetStatisListData", {params: {AreaCode: AreaCode,FillInYear: this.searchModel.FillInYear}}).then(function(res) {
          if (res.data.status == 1) {
            self.detailList = res.data.model;
            self.showType = true;            
          } else {
            self.$Modal.error({ title: "提示信息", content: res.data.message });
          }
        });
        },
        Download(){
            if(this.isCounty){
                window.open(this.$http.defaults.baseURL + "PotYearProduct/GetExcelData?FillInYear="  + this.searchModel.FillInYear + "&&AreaCode=" + this.searchModel.AreaCode);
            }
            else{
                window.open(this.$http.defaults.baseURL + "PotYearProduct/GetStatisExcel?FillInYear=" + this.searchModel.FillInYear 
                + "&&AreaCode=" + this.searchModel.AreaCode
                + "&&Type=" + this.searchModel.Type
                + "&&PVariety=" + this.searchModel.Pvariety
                );
            }
        },
        GetData(){
            // if(this.isCounty){
            //     this.getCountyListData();
            // }else{
            //     this.getListData();
            // }
          this.getListData();
        },
        rowStyle(index,length){  
            let striprow ={ backgroundColor: '#ebf7ff'};    
            if(index==(length-1)){       
                return {
                    backgroundColor: '#f9c912'
                }
            }
            else if(index%2 !=0){
                return striprow;
            }
             else{
               return 
           }
        },
        rowclass(item,index){
          let striprow ={
            backgroundColor: '#ebf7ff'
          }
          let cityrow = {
             backgroundColor: '#ff6600'
          }
          let provinrow = {
            backgroundColor: '#183'
          }
            if(index %2 ==0){
              if(item.tag==1){
                return cityrow
              }
              else if(item.tag==2){
                return provinrow
              }              
            }
            else{
              if(item.tag==1){
                return cityrow
              }
              else if(item.tag==2){
                return provinrow
              }
              else{
                return striprow
              }
            }
        },
        getListData(){
            var self = this;
            //判断当前用户是否为省级账号
            if(self.userInfo.AreaCode=="530000000000")
            {
                // self.isProvince=true;
                self.mapType=self.searchModel.AreaCode;
            }
            else{
                self.mapType=self.userInfo.AreaCode;
            }
            //柱状图
            self.AreaNameData = [];
            self.YAreaData= [];
            self.YYieldData= [];
            self.YAvgMuYieldData= [];
            self.YOutputData= [];
            self.SAreaData= [];
            self.SYieldData= [];
            self.SAvgMuYieldData= [];
            self.SOutputData= [];
            self.AAreaData= [];
            self.AYieldData= [];
            self.AAvgMuYieldData= [];
            self.AOutputData= [];
            self.WAreaData= [];
            self.WYieldData= [];
            self.WAvgMuYieldData= [];
            self.WOutputData= [];
            self.barList0=[];
            self.barList1=[];
            self.barList2=[];
            self.barList3=[];
            //地图
            self.MapYArea= [];
            self.MapYYield= [];
            self.MapYAvgMuYield= [];
            self.MapYOutput= [];
            self.MapSArea= [];
            self.MapSYield= [];
            self.MapSAvgMuYield= [];
            self.MapSOutput= [];
            self.MapAArea= [];
            self.MapAYield= [];
            self.MapAAvgMuYield= [];
            self.MapAOutput= [];
            self.MapWArea= [];
            self.MapWYield= [];
            self.MapWAvgMuYield= [];
            self.MapWOutput= [];
            self.mapList0=[];
            self.mapList1=[];
            self.mapList2=[];
            self.mapList3=[];
            self.GeoData=self.GetGeoData(self.mapType); 
            this.$http.get('PotYearProduct/GetStatisListData',{params: {AreaCode: this.searchModel.AreaCode,FillInYear: this.searchModel.FillInYear,Type:this.searchModel.Type,PVariety:this.searchModel.Pvariety}}).then(function(res){
                if(res.data.status==1){
                    self.dataList = res.data.model;
                    console.log(self.dataList)
                    //已选择品种
                    if(self.searchModel.Pvariety){
                        let list = res.data.model;
                        //去掉合计项
                        for(let i=0;i<list.length-1;i++){
                            //柱状图
                        self.AreaNameData.push(res.data.model[i].AreaName);
                        self.YAreaData.push(res.data.model[i].YArea);
                        self.YYieldData.push(res.data.model[i].YYield);
                        self.YAvgMuYieldData.push(res.data.model[i].YAvgMuYield);
                        self.YOutputData.push(res.data.model[i].YOutput);
                        self.SAreaData.push(res.data.model[i].SArea);
                        self.SYieldData.push(res.data.model[i].SYield);
                        self.SAvgMuYieldData.push(res.data.model[i].SAvgMuYield);
                        self.SOutputData.push(res.data.model[i].SOutput);
                        self.AAreaData.push(res.data.model[i].AArea);
                        self.AYieldData.push(res.data.model[i].AYield);
                        self.AAvgMuYieldData.push(res.data.model[i].AAvgMuYield);
                        self.AOutputData.push(res.data.model[i].AOutput);
                        self.WAreaData.push(res.data.model[i].WArea);
                        self.WYieldData.push(res.data.model[i].WYield);
                        self.WAvgMuYieldData.push(res.data.model[i].WAvgMuYield);
                        self.WOutputData.push(res.data.model[i].WOutput);
                        
                        //地图数据
                        self.MapYArea.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].YArea});
                        self.MapYYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].YYield});
                        self.MapYAvgMuYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].YAvgMuYield});
                        self.MapYOutput.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].YOutput});
                        self.MapSArea.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].SArea});
                        self.MapSYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].SYield});
                        self.MapSAvgMuYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].SAvgMuYield});
                        self.MapSOutput.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].SOutput});
                        self.MapAArea.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].AArea});
                        self.MapAYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].AYield});
                        self.MapAAvgMuYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].AAvgMuYield});
                        self.MapAOutput.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].AOutput});
                        self.MapWArea.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].WArea});
                        self.MapWYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].WYield});
                        self.MapWAvgMuYield.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].WAvgMuYield});
                        self.MapWOutput.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].WOutput});
                        }
                        
                        self.barList0.push(self.YAreaData,self.YYieldData,self.YAvgMuYieldData,self.YOutputData);
                        self.barList1.push(self.SAreaData,self.SYieldData,self.SAvgMuYieldData,self.SOutputData);
                        self.barList2.push(self.AAreaData,self.AYieldData,self.AAvgMuYieldData,self.AOutputData);
                        self.barList3.push(self.WAreaData,self.WYieldData,self.WAvgMuYieldData,self.WOutputData);

                        self.mapList0.push(self.MapYArea,self.MapYYield,self.MapYAvgMuYield,self.MapYOutput);
                        self.mapList1.push(self.MapSArea,self.MapSYield,self.MapSAvgMuYield,self.MapSOutput);
                        self.mapList2.push(self.MapAArea,self.MapAYield,self.MapWAvgMuYield,self.MapAOutput);
                        self.mapList3.push(self.MapWArea,self.MapWYield,self.MapWAvgMuYield,self.MapWOutput);
                        self.showEcharts();
                    }
                }else{
                    self.$Modal.error({title:'提示信息',content:res.data.message});
                }
            })
        },
        showEcharts(){//显示柱状图
            //显示柱状图
            var self=this;
            var containerBarOne=document.getElementById('divBarOne');
            var containerBarTwo=document.getElementById('divBarTwo');
            var containerBarThree=document.getElementById('divBarThree');
            var containerBarFour=document.getElementById('divBarFour');
            var containerTable=document.getElementsByClassName('ivu-col ivu-col-span-4');
            // //用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽
            var resizeContainerBar = function () {
                //containerTable[0].clientWidth 左侧菜单栏的宽度
                containerBarOne.style.width = (window.innerWidth- containerTable[0].clientWidth-40)+'px';
                containerBarOne.style.height = (window.innerHeight-280)+'px';
                containerBarTwo.style.width = (window.innerWidth- containerTable[0].clientWidth-40)+'px';
                containerBarTwo.style.height = (window.innerHeight-330)+'px';
                containerBarThree.style.width = (window.innerWidth- containerTable[0].clientWidth-40)+'px';
                containerBarThree.style.height = (window.innerHeight-330)+'px';
                containerBarFour.style.width = (window.innerWidth- containerTable[0].clientWidth-40)+'px';
                containerBarFour.style.height = (window.innerHeight-330)+'px';
            };
            //设置容器高宽
            resizeContainerBar();
            var myBarOne = myEcharts.init(containerBarOne, 'shine');
            var myBarTwo = myEcharts.init(containerBarTwo, 'shine');
            var myBarThree = myEcharts.init(containerBarThree, 'shine');
            var myBarFour = myEcharts.init(containerBarFour, 'shine');
            var BarNameOne=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯全年生产情况统计';
            var BarNameTwo=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯大春生产情况统计';
            var BarNameThree=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯秋作生产情况统计';
            var BarNameFour=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯冬作生产情况统计';
            var optionBarOne = self.GetBarOption(BarNameOne,self.AreaNameData,self.echartsItem0,self.barList0);
            var optionBarTwo = self.GetBarOption(BarNameTwo,self.AreaNameData,self.echartsItem1,self.barList1);
            var optionBarThree = self.GetBarOption(BarNameThree,self.AreaNameData,self.echartsItem2,self.barList2);
            var optionBarFour = self.GetBarOption(BarNameFour,self.AreaNameData,self.echartsItem3,self.barList3);
            myBarOne.setOption(optionBarOne);
            myBarTwo.setOption(optionBarTwo);
            myBarThree.setOption(optionBarThree);
            myBarFour.setOption(optionBarFour);
            //******************显示地图
            var self=this;
            var containerMapOne=document.getElementById('divMapOne');
            var containerMapTwo=document.getElementById('divMapTwo');
            var containerMapThree=document.getElementById('divMapThree');
            var containerMapFour=document.getElementById('divMapFour');
            // //用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽
            var resizeContainerMap = function () {
                //containerTable[0].clientWidth 左侧菜单栏的宽度
                containerMapOne.style.width = (window.innerWidth- containerTable[0].clientWidth-20)+'px';
                containerMapOne.style.height = (window.innerHeight-280)+'px';
                containerMapTwo.style.width = (window.innerWidth- containerTable[0].clientWidth-20)+'px';
                containerMapTwo.style.height = (window.innerHeight-330)+'px';
                containerMapThree.style.width = (window.innerWidth- containerTable[0].clientWidth-20)+'px';
                containerMapThree.style.height = (window.innerHeight-330)+'px';
                containerMapFour.style.width = (window.innerWidth- containerTable[0].clientWidth-20)+'px';
                containerMapFour.style.height = (window.innerHeight-330)+'px';
            };
            //设置容器高宽
            resizeContainerMap();

            var myMapOne = myEcharts.init(containerMapOne, 'shine');
            var myMapTwo = myEcharts.init(containerMapTwo, 'shine');
            var myMapThree = myEcharts.init(containerMapThree, 'shine');
            var myMapFour = myEcharts.init(containerMapFour, 'shine');
            var MapNameOne=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯全年生产情况统计';
            var MapNameTwo=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯大春生产情况统计';
            var MapNameThree=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯秋作生产情况统计';
            var MapNameFour=this.searchModel.FillInYear+'年(一)'+self.searchModel.Pvariety+'马铃薯冬作生产情况统计';
            var optionMapOne = self.GetMapOption(MapNameOne,self.GeoData,self.mapType,self.echartsItem0,self.mapList0);
            var optionMapTwo = self.GetMapOption(MapNameTwo,self.GeoData,self.mapType,self.echartsItem1,self.mapList1);
            var optionMapThree = self.GetMapOption(MapNameThree,self.GeoData,self.mapType,self.echartsItem2,self.mapList2);
            var optionMapFour = self.GetMapOption(MapNameFour,self.GeoData,self.mapType,self.echartsItem3,self.mapList3);
            console.log(optionMapOne)
            myMapOne.setOption(optionMapOne);
            myMapTwo.setOption(optionMapTwo);
            myMapThree.setOption(optionMapThree);
            myMapFour.setOption(optionMapFour);
            //用于使chart自适应高度和宽度
            window.onresize = function () {
                //重置容器高宽
                resizeContainerBar();
                resizeContainerMap();
                myMapOne.resize();
                myMapTwo.resize();
                myMapThree.resize();
                myMapFour.resize();
                myBarOne.resize();
                myBarTwo.resize();
                myBarThree.resize();
                myBarFour.resize();
            };
        },
        getCountyListData(){
            var self = this;
            this.$http.get('PotYearProduct', {params:{AreaCode:this.searchModel.AreaCode,FillInYear:this.searchModel.FillInYear}}).then(function (res) {
                if (res.data.status == 1) {
                    self.cdataList = res.data.model.list;
                }
                else {
                    self.$Modal.error({ title: '提示信息', content: res.data.message });
                }
            });
        },
    
        currentYear() {
           let year = new Date().getFullYear();
           let month = new Date().getMonth();
            if (month > 1) {
                this.searchModel.FillInYear = year.toString();
            } else {
               this.searchModel.FillInYear = (year - 1).toString();
            }
        },
        SearchCascaderChange() {
            //const index = value.length - 1;
            //this.searchModel.AreaCode = value[index];
            console.log("hdse888")
            // if(this.searchModel.AreaCode.substr(4,2) !="00"){
            //     this.isCounty = true;
            // }
            // else{
            //     this.isCounty = false;
            // }
            this.GetData();
        },
        typeChange(){
            if(this.searchModel.Type=='0'){
                this.isVariety = false;
            }
            else{
                this.isVariety = true;
            }
            this.GetData();
        },
        rowClassName(row, index){
            if (row.AreaName=='小计') {
                return 'rowCountColor'
            }
            else{
                return ''
            }

        }
    },
    //创建Vue页面方法
    created: function () {
        //this.currentYear();
       //this.SearchAreaList();
       this.AreaList = this.getChildAreaList(this.userInfo.AreaCode);
       this.getListData();
    },
    watch: {
        //需要监听的在此处新增监听对象
    }
}
</script>
